package com.hjh.netty.elect.demo5.handler;

import com.hjh.netty.elect.demo5.bean.Pmc350DevPackage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.IdleStateHandler;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * 心跳处理
 *
 * @author 程就人生
 * @date 2020年8月6日
 * @Description
 */
@Slf4j
public class Pmc350DevHandler101  extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {

        // 判断消息实例
        if (null == msg || !(msg instanceof Pmc350DevPackage)) {
            ctx.fireChannelRead(msg);
            return;
        }
        Pmc350DevPackage pmc350DevPackage  = (Pmc350DevPackage) msg;
        if(pmc350DevPackage.getPackageType() != 5){
            ctx.fireChannelRead(msg);
            return;
        }

        log.info("101：表示主站回复给终端的 ACK 报文|{}",pmc350DevPackage);
    }
}